package org.sction.security.shiro;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息.
 */
public class ShiroUser implements Serializable {
	private static final long serialVersionUID = -1748602382963711884L;
	private String username;// 帐号
	private String loginid;// 登录用帐号
	private String name;// 真实姓名
	private String userid;// 唯一编号
	private String email;// 电子邮箱
	private String cid;// 身份证
	private String mobile;// 手机号
	private String password;// 密码
	private String type;// 类型
	private String dept;// 部门
	private String group;// 分组
	private String pops;// 权限
	private String roles;// 角色
	private boolean enabled;// 是否激活
	private String siteid;// 所属站点
	private Map<String, Object> attr = new HashMap<String, Object>();

	public String getPops() {
		return pops;
	}

	public void setPops(String pops) {
		this.pops = pops;
	}

	public String getRoles() {
		return roles;
	}

	public void setRoles(String roles) {
		this.roles = roles;
	}

	public String getPassword() {
		return password;
	}

	public ShiroUser(String username, String name) {
		this.username = username;
		this.loginid = username;
		this.userid = username;
		this.name = name;
	}

	public void addAttr(String key, Object value) {
		if (this.attr == null) {
			attr = new HashMap<String, Object>();
		}
		if (value == null) {
			if (this.attr.get(key) != null) {
				attr.remove(key);
			}
		} else {
			attr.put(key, value);
		}
	}

	public Object getAttr(String key) {
		if (this.attr == null) {
			attr = new HashMap<String, Object>();
		}
		return attr.get(key);
	}

	/**
	 * 本函数输出将作为默认的<shiro:principal/>输出.
	 */
	@Override
	public String toString() {
		return username;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getLoginid() {
		return loginid;
	}

	public void setLoginid(String loginid) {
		this.loginid = loginid;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDept() {
		return dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public Map<String, Object> getAttr() {
		return attr;
	}

	public void setAttr(Map<String, Object> attr) {
		this.attr = attr;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public String getSiteid() {
		return siteid;
	}

	public void setSiteid(String siteid) {
		this.siteid = siteid;
	}

}
